//
//  main.m
//  for循环嵌套
//
//  Created by szcq on 2021/4/13.
//

#import <Foundation/Foundation.h>

int main() {
    
    for (int i = 1; i <= 3; i++) {
        //尖尖朝上  逻辑表达式  为  j<=i
        for (int j = 1; j <= i; j++) {
            printf("%d * %d = %d; ",j,i,i*j);
        }
        printf("\n");
    }
    printf("--------------------------------\n");
    for (int i = 1; i <= 3; i++) {
        //尖尖朝下  初始化赋值  为  j == i
        for (int j = i; j <= 3; j++) {
            printf("%d * %d = %d; ",i,j,i*j);
        }
        printf("\n");
    }
    
    printf("--------------------------------\n");
    for (int i = 3; i >= 1; i--) {
        //尖尖朝下  初始化赋值  为  j == i
        for (int j = i; j >= 1; j--) {
            printf("%d * %d = %d; ",i,j,i*j);
        }
        printf("\n");
    }
    
    /**
     输出结果
     1 * 1 = 1;
     1 * 2 = 2; 2 * 2 = 4;
     1 * 3 = 3; 2 * 3 = 6; 3 * 3 = 9;
     --------------------------------
     1 * 1 = 1; 1 * 2 = 2; 1 * 3 = 3;
     2 * 2 = 4; 2 * 3 = 6;
     3 * 3 = 9;
     --------------------------------
     3 * 3 = 9; 3 * 2 = 6; 3 * 1 = 3;
     2 * 2 = 4; 2 * 1 = 2;
     1 * 1 = 1;
     */
    return 0;
}
